package com.jiapu.mapper;

import com.jiapu.entity.Relationship;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

public interface RelationshipMapper {
    @Select("select * from relationship where id_del=0")
    List<Relationship> findAllr();

    @Transactional
    @Update("insert into `relationship` (`first_id`,`first_name`,`sec_id`,`sec_name`,`relation`,`id_del`) VALUES (#{first_id},#{first_name},#{sec_id},#{sec_name},#{relation},0);")
    void saver(Relationship relationship);

    @Transactional
    @Update("update relationship set first_name=#{first_name},sec_name=#{sec_name},relation=#{relation} where first_id=#{first_id} and sec_id=#{sec_id}")
    void updateByIdr(Relationship relationship);

    @Transactional
    @Update("update relationship set id_del=1 where sec_id=#{sec_id}")
    void deleteByIdr(Relationship relationship);
}
